<template>
	<view>
		<up-list @scrolltolower="scrolltolower">
			<up-list-item
				v-for="(item, index) in languageList"
				:key="index"
			>
				<up-cell @click="changeLanguage(item.locale)">
					<template #icon>
						<up-text :type="setLocale == item.locale ? 'primary' : ''" :text="item.text"></up-text>
					</template>
				</up-cell>
			</up-list-item>
		</up-list>
	</view>
</template>

<script setup>
	import { changeLocale,getLanguageList } from '../../locale/utils';
	const languageList = reactive([])
	
	const setLocale = ref()
	
	function changeLanguage(language){
		changeLocale(language);
		setLocale.value = uni.getLocale();
	}
	
	onMounted(()=>{
		languageList.push(...getLanguageList())
		setLocale.value = uni.getLocale();
	})

</script>

<style>

</style>
